package com.atguigu.tingshu.order.enumeration;

import com.atguigu.tingshu.common.constant.SystemConstant;

public enum OrderStatusEnum {

    // 定义枚举项
    ORDER_STATUS_UNPAID(SystemConstant.ORDER_STATUS_UNPAID , "未支付") ,
    ORDER_STATUS_PAID(SystemConstant.ORDER_STATUS_PAID , "已支付") ,
    ORDER_STATUS_CANCEL(SystemConstant.ORDER_STATUS_CANCEL , "已取消") ;

    private String orderStatus ;
    private String orderStatusName ;

    private OrderStatusEnum(String orderStatus , String orderStatusName) {
        this.orderStatus = orderStatus ;
        this.orderStatusName = orderStatusName ;
    }

    public static String getOrderStatusName(String orderStatus) {
        OrderStatusEnum[] orderStatusEnums = OrderStatusEnum.values();      // 获取该枚举类中的所有的枚举项
        for(OrderStatusEnum orderStatusEnum : orderStatusEnums) {
            String status = orderStatusEnum.orderStatus;
            if(status.equals(orderStatus)) {
                return orderStatusEnum.orderStatusName ;
            }
        }
        return null ;
    }

}